<?php
class Designtrip_model extends Base_Model
{
	private $_table = 'mod_ziying';
	
	public function __construct()
	{
		parent::__construct();
		$this->load->database();
	}
	
	/**
	 * 获取案例首页
	 *@param $page(int,1)
	 *@param $offset(int,0)
	 *@param $limit(int,0)
	 *@return mixed
	 * */
	public function get_anli($page = 1, $offset = 0, $limit = 10)
	{
		//筛选条件
		$where = array('zy_type'=>'CASE','status'=>'VALID');
		//分页参数
		$offset = ($page-1)*$limit;
		
		$query = $this->db->select('id,images,name,summary')->from($this->_table)->where($where)
		         ->order_by('startDay','DESC')->limit($limit,$offset)
		         ->get()->result_array();
		//图片地址处理
		foreach ($query as & $v){
			$v['images'] = $this->img($v['images']);
		}
		
		if(!empty($query)){
			return $query;
		} else {
			return FALSE;
		}
	}
	/**
	 * 获取案例详情
	 *@param $id(int)
	 * */
	public function get_anli_detail($id)
	{
		//筛选条件
		$where = array('zy_type'=>'CASE','status'=>'VALID','id'=>$id);
	
		$row = $this->db->select('descLineApp')->from($this->_table)->where($where)
		         ->get()->row_array();
		//图片地址处理
		$row['descLineApp'] = rtrim($row['descLineApp'],'|');
		$res = explode('|', $row['descLineApp']);
		
		foreach($res as & $v){
			$v = $this->img($v);
		}
	
		if(!empty($res)){
			return $res;
		} else {
			return FALSE;
		}
	}
}